<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>


<%-- Getting the theme dependent resource and img folders --%>
<spring:theme code='theme.name' var="themeName" scope="request"/>
<c:url var="rawFolder" value="/"/>
<c:set var="jsessionIdPrefix" value=";jsessionid"/>
<c:set var="rawFolder"
  value="${fn:contains(rawFolder, jsessionIdPrefix) ? fn:substringBefore(rawFolder, jsessionIdPrefix) : rawFolder}"/>
<c:set var="baseFolder" value="${rawFolder}" scope="request"/>
<c:set var="baseResFolder" value="${baseFolder}res/" scope="request"/>

<c:set var="jsFolder" value="${baseResFolder}js/" scope="request"/>
<c:set var="resFolder" value="${baseResFolder}${themeName}/" scope="request"/>
<c:set var="imgFolder" value="${resFolder}img/" scope="request"/>
<c:set var="imgProductFolder" value="${baseResFolder}productImages/" scope="request"/>

<%-- Getting the page code --%>
<c:choose>
  <c:when test="${fn:contains(pagePath, '/main.jsp')}">
    <c:set var="tmpPageCode" value="${fn:substringBefore(pagePath, '/main.jsp')}"/>
  </c:when>
  <c:when test="${fn:contains(pagePath, '/main1.jsp')}">
    <c:set var="tmpPageCode" value="${fn:substringBefore(pagePath, '/main1.jsp')}"/>
  </c:when>
  <c:when test="${fn:contains(pagePath, '/main2.jsp')}">
    <c:set var="tmpPageCode" value="${fn:substringBefore(pagePath, '/main2.jsp')}"/>
  </c:when>
  <c:otherwise>
    <c:set var="tmpPageCode" value="${fn:substringBefore(pagePath, '.jsp')}"/>
  </c:otherwise>
</c:choose>
<c:set var="tmpPageCode" value="${fn:substringAfter(tmpPageCode, '/WEB-INF/jsp/')}"/>
<c:set var="tmpPageCode"
  value="${tmpPageCode}${not empty pageNameModifier ? '/' : ''}${pageNameModifier}"/>
<c:set var="pageCode" value="${fn:replace(tmpPageCode, '/', '.')}" scope="request"/>
<c:set var="pageId" value="${fn:replace(tmpPageCode, '/', '-')}" scope="request"/>
